<!--
 * @Descripttion:人员
 * @version:
 * @Author: ada.wu
 * @Date:2024-03-11 11:26:44
 * @LastEditors: ada.wu
 * @LastEditTime: 2024-04-09 17:13:55
-->
<template>
  <div class="hub bg-white">
    <div class="t-c p-tb">
      <img src="/@/assets/report/search.svg" style="margin-top: 10vh;">
      <p v-if="!isAuth&&!isQuery" class="van-empty__description">暂无权限，请联系管理员…</p>
      <div class="fixed_bottom p-tb" style="bottom: 70px;">
        <van-button round color="#ffd000" v-if="isAuth&&!isQuery" @click="goReportHome">数据查询</van-button>
      </div>
    </div>
  </div>
  <CommonFooter report></CommonFooter>
</template>
<script lang="ts">
import CommonFooter from "/@/components/CommonFooter/index.vue";

//util
import { onMounted, reactive, toRefs, ref, nextTick } from "vue";
import { useRoute, useRouter } from "vue-router";
import { PageEnum } from "/@/enums/pageEnum";
import { useStore } from "/@/store";

//api
import { checkAuth } from "/@/api/ExamApi";

export default {
  name: "report",
  components: {
    CommonFooter,
  },
  setup() {
    const store = useStore();
    const router = useRouter();
    const route = useRoute();
    const { userid = "" } = store.state.users.userDingDTO as any;
    let { valuatorUserId = "" } = route.query;
    const state = reactive({
      isQuery: false,
      isAuth: false,
    });
    onMounted(() => {
      nextTick(() => {
        state.isQuery = true;
        checkAuth({ valuatorUserId: userid })
          .then((res: any) => {
            console.log("res==", res);
            state.isAuth = res;
          })
          .finally(() => {
            state.isQuery = false;
          });
      });
    });
    function goReportHome() {
      router.push({
        path: PageEnum.REPORT_HOME,
        query: {
          valuatorUserId:userid,
        },
      });
    }
    return {
      ...toRefs(state),
      goReportHome,
    };
  },
};
</script>

<style lang="scss" scoped>
.van-button--round {
  font-weight: 500 !important;
  font-size: 16px !important;
  color: #1a1446 !important;
  width: 200px;
}
</style>
